package com.powergisol.gis.controller;

import com.powergisol.gis.entity.TabModel;
import com.powergisol.gis.service.TabModelService;
import com.powergisol.gis.util.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

/**
 * Description:模型控制器
 */
@RestController
@RequestMapping(value = "model")
@Api(description = "模型管理" ,value = "模型管理")
public class TabModelController extends BaseController{
    @Autowired
    private TabModelService tabModelService;


    @RequestMapping(value = "saveModel", method = RequestMethod.POST)
    @ApiOperation(value = "模型属性保存", notes = "模型属性保存")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "String", name = "modelName", value = "对象名称",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "String", name = "modelRemark", value = "备注",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Integer", name = "modelType", value = "模型类型",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelLon", value = "经度",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelLat", value = "纬度",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelH", value = "高程",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Integer", name = "modelHtype", value = "高度模式(1=紧贴地表2=相对地表3=海拔高度)",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Integer", name = "modelPoint", value = "位置瞄点(1=底部中心2=顶部中心3=中心)", required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelTimes", value = "缩放倍数",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "String", name = "serviceName", value = "服务名称",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Integer", name = "sceneId", value = "场景id",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelX", value = "x角度",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelY", value = "y角度", required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelZ", value = "z角度",  required = false, paramType = "query")
    })
    public Result saveModel(TabModel tabModel){
        return tabModelService.insertSelective(tabModel);
    }


    @RequestMapping(value = "upModel", method = RequestMethod.POST)
    @ApiOperation(value = "模型属性修改", notes = "模型属性修改")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "Integer", name = "id", value = "模型属性id",  required = true, paramType = "query"),
            @ApiImplicitParam(dataType = "String", name = "modelName", value = "对象名称",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "String", name = "modelRemark", value = "备注",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Integer", name = "modelType", value = "模型类型",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelLon", value = "经度",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelLat", value = "纬度", required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelH", value = "高程",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Integer", name = "modelHtype", value = "高度模式(1=紧贴地表2=相对地表3=海拔高度)",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Integer", name = "modelPoint", value = "位置瞄点(1=底部中心2=顶部中心3=中心)",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelTimes", value = "缩放倍数",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "String", name = "serviceName", value = "服务名称", required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Integer", name = "sceneId", value = "场景id",  required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelX", value = "x角度",required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelY", value = "y角度", required = false, paramType = "query"),
            @ApiImplicitParam(dataType = "Double", name = "modelZ", value = "z角度",  required = false, paramType = "query")
    })
    public Result upModel(TabModel tabModel){
        return tabModelService.updateTabModel(tabModel);
    }

    @RequestMapping(value = "getModel", method = RequestMethod.POST)
    @ApiOperation(value = "根据场景id和服务名称获取模型属性详情", notes = "根据场景id和服务名称获取模型属性详情")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "Integer", name = "sceneId", value = "场景id", required = true, paramType = "query"),
            @ApiImplicitParam(dataType = "String", name = "serviceName", value = "服务名称",  required = true, paramType = "query")
    })
    public Result getModel(Integer sceneId,String serviceName){

        return tabModelService.selectByCondition(sceneId,serviceName);
    }

    @RequestMapping(value = "delModel", method = RequestMethod.POST)
    @ApiOperation(value = "根据场景id和服务名称删除模型", notes = "根据场景id和服务名称删除模型")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "Integer", name = "sceneId", value = "场景id", required = true, paramType = "query"),
            @ApiImplicitParam(dataType = "String", name = "serviceName", value = "服务名称",  required = true, paramType = "query")
    })
    public Result delModel(Integer sceneId,String serviceName){

        return tabModelService.delModel(sceneId,serviceName);
    }

    @RequestMapping(value = "getStatic", method = RequestMethod.POST)
    @ApiOperation(value = "根据静态值num获取下拉框值（staticNum=7：高度模式；staticNum=8：位置瞄点）", notes = "根据静态值num获取下拉框值")
    @ApiImplicitParams({
            @ApiImplicitParam(dataType = "Integer", name = "staticNum", value = "静态值num",  required = true, paramType = "query")
    })
    public Result getStatic(Integer staticNum){

        return tabModelService.getStatic(staticNum);
    }




}
